﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Twinkle.Dialogs.Account
{
    public partial class AccountConfirmer : Form
    {
        public enum LinkType { Post, RT, Fav };
        private LinkType linkType;
        private bool UseForUpdate = true;

        public AccountConfirmer(LinkType link)
        {
            InitializeComponent();
            linkType = link;
            UseForUpdate = link == LinkType.Post;
        }

        private void PostConfirmer_Load(object sender, EventArgs e)
        {
            foreach(var a in Kernel.Config.Accounts)
            {
                accoutsList.Items.Add(a.UserId, a.UseForUpdate);
            }
        }

        private void OKBtn_Click(object sender, EventArgs e)
        {
            for(int i = 0;i < accoutsList.Items.Count; i++)
            {
                if (UseForUpdate)
                    Kernel.Config.Accounts[i].UseForUpdate = accoutsList.CheckedIndices.Contains(i);
                else
                    Kernel.Config.Accounts[i].UseForOperate = accoutsList.CheckedIndices.Contains(i);
            }
            switch (linkType)
            {
                case LinkType.Post:
                    Kernel.Config.Behavior.ConfirmAccountsBeforePost = !notAskAgain.Checked;
                    break;
                case LinkType.RT:
                    Kernel.Config.Behavior.ConfirmAccountsBeforeRT = !notAskAgain.Checked;
                    break;
                case LinkType.Fav:
                    Kernel.Config.Behavior.ConfirmAccountsBeforeFav = !notAskAgain.Checked;
                    break;
            }
        }
    }
}
